<?php
namespace pays;
class PayApi
{
    private $config;
    public function __construct($config)
    {
        $this->config = $config;
    }
    public function gateway($paytype = 'wechatpay')
    {
        return $this->driver($paytype);
    }
    protected function driver($paytype){
        if (!file_exists(__DIR__ . '/Gateways/' . strtolower($paytype) . '/' . ucfirst($paytype) . '.php')) {
            exit("Gateway [<span style='color:red'>" . ucfirst($paytype) . "</span>] is not supported.");
        }
        $gateway = __NAMESPACE__ . '\\Gateways\\' .strtolower($paytype) .'\\'. ucfirst($paytype);
        return new $gateway($this->config);
    }
}
